import {
  auditList,
  auditPass
} from '@/api/audit'
import utils from '@/utils/common'
var timeStamp = Number(new Date())
const audit = {
  state: {},

  mutations: {},

  actions: {
    // 审核列表
    AuditList ({
      getters
    }, data) {
      const loginParams = {
        token: utils.AuthToken(timeStamp, getters.userKey),
        adminId: getters.adminId,
        timestamp: timeStamp,
        keyword: data.keyword,
        appTypeId: data.appTypeId,
        status: data.status,
        startTime: data.startTime,
        endTime: data.endTime,
        page: data.page,
        pageSize: data.pageSize
      }
      return new Promise((resolve, reject) => {
        auditList(loginParams).then(response => {
          resolve(response)
        }).catch(error => {
          reject(error)
        })
      })
    },
    // 审核通过或拒绝
    AuditPass ({
      getters
    }, data) {
      const loginParams = {
        token: utils.AuthToken(timeStamp, getters.userKey),
        adminId: getters.adminId,
        timestamp: timeStamp,
        id: data.id,
        status: data.status,
        notification: data.notification || '',
        rejectType: data.rejectType || '',
        rejectReason: data.rejectReason || ''
      }
      return new Promise((resolve, reject) => {
        auditPass(loginParams).then(response => {
          resolve(response)
        }).catch(error => {
          reject(error)
        })
      })
    }

  }
}

export default audit
